class Person:
    def __init__(self,name,age):
        self.__name = name
        # __name  私有成员
        self._age = age
        # _age  保护成员

    @property
    def name(self):
        print("执行获取")
        return self.__name

    @name.setter
    def name(self,name):
        print("执行设置")
        if 2<=len(name)<=4:
            self.__name=name
        else:
            print("设置不合法")

    @property
    def age(self):
        print("执行年龄获取")
        return self._age

    @age.setter
    def age(self,age):
        print("执行年龄设置")
        if 0<=age<=100:
            self._age=age
        else:
            print("年龄设置不合法")
p=Person('张三',60)
# print(p.__name)    __name  为私有数据  类外不可访问
print(p.name)
p.name = "李四"
print(p.name)
# _age 为保护数据  类外不建议访问
print(p._age)

class PersonManage(Person):
    def get_age(self):
        return self._age

pm = PersonManage("钢铁侠",50)
print(pm.age,pm.get_age())